<?php

namespace App\Http\Requests\Order;

use Illuminate\Foundation\Http\FormRequest;

class OrderRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'oprator_name'              => 'required|max:25',
                        'sp_name'                   => 'required|max:25',
                        'order_no'                  => 'required|max:50',
                        'amount'                    => 'required|numeric|between:0,9999999999.99',
                        'pay_state'                 => 'required',
                        'is_support_reconciliation' => 'required',
                        'price_type'                => 'required',
                        'mac'                       => 'required',
                        'card_id'                   => 'required|max:50',
                        'content_id'                => 'required|max:50',
                        'result'                    => 'required',
                        'service_code'              => 'required|max:50',
                        'service_type'              => 'required',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    $id = $this->route('orders');
                    return [
                        'oprator_name'              => 'required|max:25',
                        'sp_name'                   => 'required|max:25',
                        'order_no'                  => 'required|max:50',
                        'amount'                    => 'required|numeric|between:0,9999999999.99',
                        'pay_state'                 => 'required',
                        'is_support_reconciliation' => 'required',
                        'price_type'                => 'required',
                        'mac'                       => 'required',
                        'card_id'                   => 'required|max:50',
                        'content_id'                => 'required|max:50',
                        'result'                    => 'required',
                        'service_code'              => 'required|max:50',
                        'service_type'              => 'required',
                    ];
                }
            default:
                break;
        }
    }
}
